VHS Change Queue
The VHS change queue is a service file (VhsChangeQueue.dat) that keeps track of incremental changes to a VHS. Every change made to a VHS (new values added, deleting points, editing values, etc.) will be stored on the change queue. This allows a client to quickly retrieve any changes made to the source VHS since the last time it was checked. In some situations this can be a much faster method of retrieval than iterating points and values directly.
The VHS Change Queue is used by VHS Replication and VHS Quick Recovery. A replicated VHS uses the change queue of its source to keep track of where it is in the replication process. Quick Recovery uses the archived change queue to add the most recent changes back into the new database after a recovery event.
The VHS maintains a sequence number that identifies each change made to the database. The sequence number is incremented each time a change is made, and a sequence number is assigned to that change. When a client asks for changes, it provides the last sequence number that it knew about, and the VHS will provide all incremental changes from its change queue since that sequence. All information about a change to the VHS is contained within an item on the change queue, so once the client receives these changes it has everything it needs to know about what happened to the VHS.
The VHS creates the change queue as a file in the service directory. This file is maintained as a memory-mapped file, so internal access to it is very fast. As such, the change queue consumes virtual memory for the VHS process. The change queue size is configured in the VHS configuration file. The keyword CHANGE_QUEUE_SIZE configures the number of entries allocated on the change queue. The minimum number is 500,000 and the maximum number is 5,000,000. If no value is specified, then the minimum size will be used by default. The minimum change queue size results in a data file of size 33.6 MB, while the maximum change queue size results in a data file of size 336 MB.
Note: If an improper shutdown is detected or the change queue size configuration is changed, the items on the change queue will be deleted. However, if an improper shutdown is detected and Quick Recovery is enabled, the change queue will be archived off, along with the "dirty" database.
Change Queue Wrapping
Since the change queue has a finite size, when the VHS accumulates a number of changes greater than the change queue size, the new changes are then written to the beginning position of the queue. The oldest changes on the queue get overwritten when this happens. Once the change queue is full, new incremental changes will overwrite the oldest changes on the queue.

